//
//  PickView.swift
//  swiftUIdemo
//
//  Created by Z.cy on 2025/1/9.
//

import SwiftUI

struct PickView: View {
    var card: UserCard
    var blur: Bool
    var body: some View {
        GeometryReader { proxy in
            if let photo = card.photos.first {
                ZStack(alignment: .bottomLeading) {
                    Image(photo)
                        .resizable()
                        .frame(width: proxy.size.width, height: proxy.size.height)
                        .aspectRatio(contentMode: .fill)
                        .if(blur) {
                            $0.blur(radius: 25)
                        }
                    Text("\(card.name)\n\(card.age)")
                        .padding()
                        .foregroundColor(.white)
                        .font(.system(size: 18, weight: .semibold))
                        .if(blur) {
                            $0.redacted(reason: .placeholder)
                        }
                }
                .cornerRadius(16)
            }
        }
    }
}

struct PickView_Previews: PreviewProvider {
    static var previews: some View {
        let card = UserCard(name: "Natalia", age: 22, place: "Vadalia NYC", zodiac: "Cancer", photos: ["User1", "User2"])
        PickView(card: card, blur: true)
            .frame(width: 200, height: 300)
    }
}
